/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package xml;

import java.beans.XMLDecoder;
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import model.Te_Info_Model;
import view.Te_Login_View;

/**
 *
 * @author 马凯
 */
public class Te_Info_XML {
    private static Te_Info_XML tix;
    private String path;
    
    public static Te_Info_XML getInstance(Te_Login_View tlv){
        if(tix==null){
            tix = new Te_Info_XML();
            tix.path = tlv.getIDModel().getUserID();
        }
        return tix;
    }
    
    public Te_Info_Model run(){
        try{
            System.out.println("The path is " + this.path + ".xml");
            XMLDecoder decoder =
                    new XMLDecoder(
                    new BufferedInputStream(new FileInputStream(this.path+".xml")));
            Te_Info_Model tim = (Te_Info_Model) decoder.readObject();
            return tim;
        }catch(Exception e){
            e.printStackTrace();
            return null;
        }
    }
}
